﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace SLRTHackathon.Views
{
    public partial class MusicPage : PhoneApplicationPage
    {
        public MusicPage()
        {
            InitializeComponent();
        }


        private void PlayBtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (MediaLibrary library = new MediaLibrary())
                {
                    MediaPlayer.Play(library.Songs);
                }
            }
            catch (InvalidOperationException ex) { }
 
            PauseBtn.Visibility = Visibility.Visible;
            PlayBtn.Visibility = Visibility.Collapsed;
        }

        private void BackBtn_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Views/CarDockPage.xaml", UriKind.RelativeOrAbsolute));
        }

        private void ReplayBtn_Click(object sender, RoutedEventArgs e)
        {
            Song song = MediaPlayer.Queue.ActiveSong;
            MediaPlayer.Stop();
            MediaPlayer.Play(song);
        }

        private void PrevBtn_Click(object sender, RoutedEventArgs e)
        {
            MediaPlayer.MovePrevious();
        }

        private void NextBtn_Click(object sender, RoutedEventArgs e)
        {
            MediaPlayer.MoveNext();
        }

        private void PauseBtn_Click(object sender, RoutedEventArgs e)
        {
            MediaPlayer.Pause();
            PlayBtn.Visibility = Visibility.Visible;
            PauseBtn.Visibility = Visibility.Collapsed;
        }

        private void StopBtn_Click(object sender, RoutedEventArgs e)
        {
            MediaPlayer.Stop();
        }

    }
}